package main

import (
	"flag"
	"fmt"
	"yim_server/core"
	"yim_server/yim_chat/chat_models"
	"yim_server/yim_file/file_models"
	"yim_server/yim_group/group_models"
	"yim_server/yim_user/user_models"
)

type Option struct {
	DB bool
}

func main() {
	var opt Option
	flag.BoolVar(&opt.DB, "db", false, "db")

	flag.Parse()

	if opt.DB {
		db := core.InitGorm("root:123456@tcp(127.0.0.1:3306)/yim_server_db?charset=utf8mb4&parseTime=True&loc=Local")
		err := db.AutoMigrate(
			&user_models.UserModel{},
			&user_models.UserFriendModel{},
			&user_models.UserConfigModel{},
			&user_models.UserFriendVerifyModel{},

			&chat_models.ChatModel{},
			&group_models.GroupModel{},
			&group_models.GroupMemberModel{},
			&group_models.GroupMsgModel{},
			&group_models.GroupVerifyModel{},
			&file_models.FileModels{},
		)
		if err != nil {
			fmt.Println("表结构创建失败", err)
			return
		}

		fmt.Println("表结构创建成功")
	}
}
